/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package view;

import java.io.IOException;
import java.util.Timer;
import java.util.TimerTask;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

/**
 *
 * @author hrtz
 */
public class SplashScreen extends Canvas{
    private Midlet midlet;
    private Image imageSeamolec;
    private Timer timer;

    public SplashScreen(Midlet midlet) {
        this.midlet = midlet;
        timer = new Timer();
        timer.schedule(new TimerTask() {

            public void run() {
                dismiss();
            }
        }, 2000);

        try {
            imageSeamolec = Image.createImage("/res/logo_seamolec.jpg");
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }

    protected void paint(Graphics g) {
       g.setColor(255,255,255);
       g.fillRect(0,0,getWidth(), getHeight());
       g.drawImage(imageSeamolec, getWidth()/2, getHeight()/2, Graphics.HCENTER | Graphics.VCENTER);
    }

    protected void keyPressed(int keyCode) {
        timer.cancel();
        dismiss();
    }

    private void dismiss() {
        midlet.displayMainMenu();
    }



}
